<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../plugins/vue.min.js"></script>
</head>
<body>
    <div id="box">
        <input type="text" ref="mytext" v-model="myNames">
        <ul ref="myLi">
            <li>111</li>
            <li>222</li>
            <li>333</li>
        </ul>
        <button @click="getRef"> add</button>
        <child ref="child"></child>
    </div>
    <script>
        Vue.component("child",{
            data(){
                return{
                    myname:"我的名字"
                }
            },
            template:`
            <div>
                 clile ---{{myname}}
                 </div>
            `
        })
        let vm =  new Vue({
            el:"#box",
            data(){
                return{
                    myNames : "新奇"

                }
            },
            methods:{
                getRef(){
                //    拿到的是dom对象,节点
                    console.log(this.$refs)
                    console.log(this.$refs.mytext.value)
                    console.log(this.$refs.mytext)

                    // 组件,拿到的是组件对象,可以拿到里面的值
                    // console.log(this.$refs.child)
                    // console.log(this.$refs.child.myname)
                    // 也可以直接修改值
                    // this.$refs.child.myname = "kkkk"
                    // console.log(this.$refs.child.myname)
                }
            }

        })
    </script>
</body>
</html>